package com.jhy.study2.IO;


import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * @author: robert
 * @description: 单个文件解压缩
 * @date: 2021/8/23 19:38
 * @return
 */
public class SingleFileUnzip1 {
    public static void main(String[] args) throws Exception {

        File file = new File("D://folder1//abc.zip");



        //读取
        ZipInputStream zipInputStream = null;
        zipInputStream = new ZipInputStream(new FileInputStream(file));
        ZipEntry nextEntry = zipInputStream.getNextEntry();
        System.out.println("压缩体名称：" + nextEntry.getName());

        //输出
        File file2 = new File("D://unzip//"+ nextEntry.getName());
        OutputStream out = new FileOutputStream(file2);
        int temp = 0;
        while((temp = zipInputStream.read()) != -1){
            out.write(temp);
        }

        zipInputStream.close();
        out.close();



    }

}
